﻿Imports FairShop
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports FairShop.Operaties

'''<summary>
'''This is a test class for DalTest and is intended
'''to contain all DalTest Unit Tests
'''</summary>
<TestClass()> _
Public Class TestBL

    Private testContextInstance As TestContext

    '''<summary>
    '''Gets or sets the test context which provides
    '''information about and functionality for the current test run.
    '''</summary>
    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(ByVal value As TestContext)
            testContextInstance = value
        End Set
    End Property

#Region "Additional test attributes"
    '
    'You can use the following additional attributes as you write your tests:
    '
    'Use ClassInitialize to run code before running the first test in the class
    <ClassInitialize()> _
    Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
        AppDomain.CurrentDomain.SetData("APPBASE", Environment.CurrentDirectory)
    End Sub
    '
    'Use ClassCleanup to run code after all tests in a class have run
    '<ClassCleanup()>  _
    'Public Shared Sub MyClassCleanup()
    'End Sub
    '
    'Use TestInitialize to run code before running each test
    '<TestInitialize()>  _
    'Public Sub MyTestInitialize()
    'End Sub
    '
    'Use TestCleanup to run code after each test has run
    '<TestCleanup()>  _
    'Public Sub MyTestCleanup()
    'End Sub
    '
#End Region

    '''<summary>
    '''A test for GetArtikelHistoriek
    '''</summary>
    <TestMethod()> _
    Public Sub EmailadresToevoegenTest()
        TestEmail(EmailadressenBL.ResultType.OK, "test@test.be")

        TestEmail(EmailadressenBL.ResultType.SlechtAdres, "")
        TestEmail(EmailadressenBL.ResultType.SlechtAdres, "test.test.be")

        EmailadressenBL.EmailadresToevoegen("test@test.be")
        TestEmail(EmailadressenBL.ResultType.BestondAl, "test@test.be")
    End Sub

    Private Sub TestEmail(ByVal expectedResult As EmailadressenBL.ResultType, ByVal testadres As String)
        Try
            Dim actual As EmailadressenBL.ResultType = EmailadressenBL.EmailadresToevoegen(testadres)
            Assert.AreEqual(expectedResult, actual)
        Finally
            Dim dal As New TestDal()
            dal.TestContext = Me.TestContext
            dal.CleanUpEmailadres(testadres)
        End Try
    End Sub

End Class
